﻿using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoreLibrary.Email {

    public class SendEmailRequest {
        
        public List<EmailAddress> To  { get; set; }
        public List<EmailAddress> Cc  { get; set; }
        public List<EmailAddress> Bcc { get; set; }
        public EmailAddress ReplyTo   { get; set; }
        public EmailAddress From      { get; set; }

        public string Subject  { get; set; }
        public string TextBody { get; set; }
        public string HtmlBody { get; set; }

        public List<EmailAttachment> EmailAttachments { get; set; }

        public SendEmailRequest() {
            EmailAttachments = new List<EmailAttachment>();
            To  = new List<EmailAddress>();
            Cc  = new List<EmailAddress>();
            Bcc = new List<EmailAddress>();
        }

        public string ToDebugString() {
            return new StringBuilder(200)
                      .AppendLine(">> From <<")
                      .AppendLine(From.Email)
                      .AppendLine(">> To <<")
                      .AppendLine(StringUtil.Join(",", To.Select(a => a.Email).ToList(), true))
                      .AppendLine(">> Subject <<")
                      .AppendLine(Subject)
                      .AppendLine(">> Text Body <<")
                      .AppendLine(TextBody)
                      .AppendLine(">> Html Body <<")
                      .AppendLine(HtmlBody)
                      .ToString();
        }
    }
}